/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package id2212.homework2;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.rmi.RemoteException;
import java.util.logging.Level;
import java.util.logging.Logger;
import marketrmi.AccountClientInter;
import marketrmi.ItemInter;

/**
 *
 * @author Guillaume
 */
public class BtnWishActionListener implements ActionListener {

    private ItemInter m_item;
    private AccountClientInter m_acc;

    public BtnWishActionListener(ItemInter item, AccountClientInter acc) {
        m_item = item;
        m_acc = acc;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        try {
            String str1 = m_acc.getClientName();
            String str2 = m_item.getSellerName();
            if (!str1.equalsIgnoreCase(str2) ) {
                System.out.println("button wish was cliqued");
                new Wish_ui(m_item, m_acc);
            }
            else{
                System.out.println("The seller can't make a wish on his own item");
            }
        } catch (RemoteException ex) {
            Logger.getLogger(BtnWishActionListener.class.getName()).log(Level.SEVERE, null, ex);

        }

    }
}
